using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace _0912089_0912172
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        #region Fields

        GraphicsDeviceManager graphics;

        public GraphicsDeviceManager Graphics
        {
            get { return graphics; }
        }
        List<DrawableGameComponent> lstComponent = new List<DrawableGameComponent>();
        #endregion

        #region Initialization

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            if (Global.gameSetting.IsFullScreen)
            {
                graphics.IsFullScreen = true;
                graphics.ApplyChanges();
            }



        }

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            base.Initialize();
            SetFullScreen();
            Global.clickSoundEffect = Content.Load<SoundEffect>(@"Resources/SoundsEffect/clickclick1");
            Global.footStepEffect =Content.Load<SoundEffect>(@"Resources/SoundsEffect/footsteps2");
            Global.backgroundMusic = Content.Load<Song>(@"Resources/Songs/Nightmare - Avenged Sevenfold");
           // this.IsMouseVisible = true;
        }

        private void SetFullScreen()
        {
            graphics.PreferredBackBufferWidth = 1024;
            graphics.PreferredBackBufferHeight = 768;
            graphics.PreferMultiSampling = false;
            //graphics.IsFullScreen = true;
            graphics.ApplyChanges();
        }

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            Global.gameMode = Global.GAME_MODE.TRAILER;
            //Components.Add(new TrailerScreen(this));
        }
        #endregion


        /// <summary>
        /// UnloadContent will be called once per game and is the place to unload
        /// all content.
        /// </summary>
        protected override void UnloadContent()
        {
            // TODO: Unload any non ContentManager content here
        }

        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>

        #region Update and Draw

        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            switch (Global.gameMode)
            {
                case Global.GAME_MODE.TRAILER:
                    if(Components.Count == 0)
                        Components.Add(new TrailerScreen(this));
                    break;
                case Global.GAME_MODE.MAIN_MENU:
                    /*if (Components.Count == 0)
                        Components.Add(new MenuScreen(this));*/
                    break;
                case Global.GAME_MODE.PLAYING:
                    /*if (Components.Count == 0)
                        Components.Add(new PlayingScreen(this));*/
                    break;
                case Global.GAME_MODE.QUIT:
                    Exit();
                    break;
            }
        }

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
        }
        #endregion
    }
}
